function names = writeClusterLists( file_lists , root ,affix)
    dataset_n = length( file_lists );
    
    clear names;
    j = 0;
    for i = 1:dataset_n
        
        temp = writeClusterList( file_lists{i} , root ,affix);
        for k = 1:length(temp)
            j = j+1;
            names{j} = temp{k};
        end
    end
end

function names = writeClusterList( lists, root , affix)
    cluster_n = length( lists );
    names = cell( cluster_n );
    for i = 1:cluster_n        
        [src_name, gt_name ] = writeCluster( lists{i}, root , i,affix);
        names{i}.src_name = src_name;
        names{i}.gt_name = gt_name;
        names{i}.cluster_id = i;
        names{i}.affix = affix;
        names{i}.name = lists{i}.name;
    end
end

function [fout_src_name,fout_gt_name] = writeCluster( list, root ,cluster_id, affix)

    veb = 1;
    
    n = length( list.src );
    
    fout_src_name = [root list.name '_' affix '_c' num2str( cluster_id ) '_src.txt'];
    fout_gt_name = [root list.name '_' affix '_c'  num2str( cluster_id ) '_gt.txt'];
    
    fout_src = fopen(fout_src_name, 'wt');
    fout_gt  = fopen(fout_gt_name , 'wt');
    
    fprintf( fout_src ,'%d\n', n );
    fprintf( fout_gt  ,'%d\n', n );
    
    for j = 1:n
        fprintf( fout_src , '%s\n', list.src{j} );
        fprintf( fout_gt  , '%s\n', list.gt{j} );
    end
    
    fclose( fout_src );
    fclose( fout_gt );
       
    
end